<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%   
String path = request.getContextPath();   
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";   
%> 
<!DOCTYPE html>
<html>
<head>
    <title>问答社交</title>
    <base href="<%=basePath%>"> 
    <link rel="shortcut icon" href="<%=basePath%>img/favo.ico">
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/todc-bootstrap.css" rel="stylesheet">
    <link href="css/global.css" rel="stylesheet">
    <link href="css/layout.css" rel="stylesheet">
    <link href="css/user.css" rel="stylesheet">
    <link href="css/main.css" rel="stylesheet">
    
    <script type="text/javascript" src="<%=basePath%>js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/bootstrap.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/common.js"></script>
</head>
<body>
<jsp:include page="include/topbar.jsp"></jsp:include>
<jsp:include page="include/logobar.jsp"></jsp:include>
<div class="layout grid-m0s5 index">
	<div class="main-wrap">
		<div class="box">
			<div class="hd tl">
				<h3>最热答案</h3>
			</div>
			<ul class="bd unstyled list">
			<c:forEach var='map' items='${hotQuestion }'>
            	<li class='question event'>
				  <div class='head'>
				  		<img src='upload/head/${map.user_head }?s=50' onerror='this.src="upload/head/m/default.jpg?s=50"'/>
				  		<c:choose>
			 				<c:when test="${map.is_anonymous==0 }">
			 					<a href="c/home/${map.user_by_id }.html"><img src='upload/head/${map.user_by_head}?s=50' onerror='this.src="upload/head/default.jpg?s=50"'/></a>
			 				</c:when>
			 				<c:otherwise>
			 					<img src='upload/head/anony.jpg?s=50' onerror='this.src="upload/head/default.jpg?s=50"'/>
			 				</c:otherwise>
			 			</c:choose>
				 		
				 		<span class='action'>答</span>
				 		<c:if test="${map.is_public==0 }">
		 					<span class='lock'><img src="img/lock.gif" title='不公开'/></span>
		 				</c:if>
				  </div>
				  <div class='body'>
				 	<div class='hd'>
				 		<p>
				 			<span class='name'>
				 				<a href="c/home/${map.user_id }.html">${map.user_name}</a>
				 			</span>
				 			<span>&nbsp;回答&nbsp;</span>
				 			<c:choose>
				 				<c:when test="${map.is_anonymous==0 }">
				 					<span class='name'><a href="c/home/${map.user_by_id }.html">${map.user_by_name}</a></span>
				 				</c:when>
				 				<c:otherwise>
				 					<span class='name'>路人甲:</span>
				 				</c:otherwise>
				 			</c:choose>
				         ${map.question }
				 		</p>
				 	</div> 
				 	<div class='bd' style="display:none;">
				 			${map.answer }
				 	</div>
				 	<div class="ft">
						<a onclick="takeGlance(this)">瞥一眼</a>&nbsp;&nbsp;<a class="fr" href="c/q/${map.id }.html">详细&nbsp;<i class="icon-eye-open"></i></a>
				 	</div>
				 </div> 
			 	</li> 
             </c:forEach>
			</ul>
		</div>
		
		<div class="box">
			<div class="hd tl">
				<h3>活跃用户</h3>
			</div>
			<ul class="bd unstyled inline userlist">
				<c:forEach items="${activeUsers }" var="cuser">
					<li style="width:80px;">
						<p>
						<img src="upload/head/${cuser.head_img }?s=50" onerror='this.src="upload/head/default.jpg?s=50"'/>&nbsp;&nbsp;
						</p>
						<p>
						<a href="c/home/${cuser.id }.html">
						<c:if test="${fn:length(cuser.name)>10 }">
							${fn:substring(cuser.name, 0, 10)}
						</c:if>
						<c:if test="${fn:length(cuser.name)<=10 }">
							${cuser.name }
						</c:if>
						</a>
					</li>
				</c:forEach>
			</ul>
		</div>
		
		<div class="box">
			<div class="hd tl">
				<h3>最新答案</h3>
			</div>
			<ul class="bd unstyled list">
				<c:forEach var='map' items='${newQuestion }'>
            	<li class='question event'>
				  <div class='head'>
				  		<img src='upload/head/${map.user_head }?s=50' onerror='this.src="upload/head/default.jpg?s=50"'/>
				  		<c:choose>
			 				<c:when test="${map.is_anonymous==0 }">
			 					<a href="c/home/${map.user_by_id }.html"><img src='upload/head/${map.user_by_head}?s=50' onerror='this.src="upload/head/default.jpg?s=50"'/></a>
			 				</c:when>
			 				<c:otherwise>
			 					<img src='upload/head/anony.jpg?s=50' onerror='this.src="upload/head/default.jpg?s=50"'/>
			 				</c:otherwise>
			 			</c:choose>
				 		
				 		<span class='action'>答</span>
				 		<c:if test="${map.is_public==0 }">
		 					<span class='lock'><img src="img/lock.gif" title='不公开'/></span>
		 				</c:if>
				  </div>
				  <div class='body'>
				 	<div class='hd'>
				 		<p>
				 			<span class='name'>
				 				<a href="c/home/${map.user_id }.html">${map.user_name}</a>
				 			</span>
				 			<span>&nbsp;回答&nbsp;</span>
				 			<c:choose>
				 				<c:when test="${map.is_anonymous==0 }">
				 					<span class='name'><a href="c/home/${map.user_by_id }.html">${map.user_by_name}</a></span>
				 				</c:when>
				 				<c:otherwise>
				 					<span class='name'>路人甲:</span>
				 				</c:otherwise>
				 			</c:choose>
				         ${map.question }
				 		</p>
				 	</div> 
				 	<div class='bd' style="display:none">
				 			${map.answer }
				 	</div>
				 	<div class="ft">
						<a onclick="takeGlance(this)">瞥一眼</a>&nbsp;&nbsp;<a class="fr" href="c/q/${map.id }.html">详细&nbsp;<i class="icon-eye-open"></i></a>
				 	</div>
				 </div> 
			 	</li> 
             </c:forEach>
			</ul>
		</div>
	</div>
	<div class="col-extra">
		<div class="box">
			<div class="hd tl">
				<h3>推荐用户</h3>
			</div>
			<ul class="bd unstyled inline userlist">
				<c:forEach items="${hotUsers }" var="cuser">
					<li style="width:80px;">
						<p>
						<img src="upload/head/${cuser.head_img }?s=50" onerror='this.src="upload/head/default.jpg?s=50"'/>&nbsp;&nbsp;
						</p>
						<p>
						<a href="c/home/${cuser.id }.html">
						<c:if test="${fn:length(cuser.name)>10 }">
							${fn:substring(cuser.name, 0, 10)}
						</c:if>
						<c:if test="${fn:length(cuser.name)<=10 }">
							${cuser.name }
						</c:if>
						</a>
					</li>
				</c:forEach>
			</ul>
		</div>
		
		<div class="box">
			<div class="hd tl">
				<h3>最受欢迎</h3>
			</div>
			<ul class="bd unstyled list">
				<c:forEach items="${hotArticle }" var="article">
					<li>
						<img src="upload/head/${article.user.headImg }?s=24" onerror='this.src="upload/head/default.jpg?s=24"'/>&nbsp;&nbsp;<a href="c/a/${article.id }.html">
						<c:if test="${fn:length(article.title)>25 }">
							${fn:substring(article.title, 0, 22)}...
						</c:if>
						<c:if test="${fn:length(article.title)<=25 }">
							${article.title }
						</c:if>
						</a>
					</li>
				</c:forEach>
			</ul>
		</div>
		<div class="box">
			<div class="hd tl">
				<h3>热门标签</h3>
			</div>
			<div>
			<c:forEach var="tag" items="${hottags }">
				<span class="bage">&nbsp;${tag.name }&nbsp;</span>
			</c:forEach>
			</div>
		</div>
		
		<div class="box">
			<div class="hd tl">
				<h3>正在念叨</h3>
			</div>
			<ul class="bd unstyled list">
				<c:forEach items="${newArticle }" var="article">
					<li>
						<img src="upload/head/${article.user.headImg }?s=24" onerror='this.src="upload/head/default.jpg?s=24"'/>&nbsp;&nbsp;<a href="c/a/${article.id }.html">
						<c:if test="${fn:length(article.title)>25 }">
							${fn:substring(article.title, 0, 22)}...
						</c:if>
						<c:if test="${fn:length(article.title)<=25 }">
							${article.title }
						</c:if>
						</a>
					</li>
				</c:forEach>
			</ul>
		</div>
	</div>

</div>
<jsp:include page="include/foot.jsp"></jsp:include>
</body>
</html>